/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.classnet.db;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 *
 * @author karltinawi
 */
@Entity
@Table(name = "admin")
@NamedQueries({@NamedQuery(name = "Admin.findByUser", query = "SELECT a FROM Admin a WHERE a.user = :user")})
public class Admin implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "user", nullable = false)
    private String user;
    @JoinColumn(name = "user", referencedColumnName = "email", insertable = false, updatable = false)
    @OneToOne
    private User user1;

    public Admin() {
    }

    public Admin(String user) {
        this.user = user;
    }

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public User getUser1() {
        return user1;
    }

    public void setUser1(User user1) {
        this.user1 = user1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (user != null ? user.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Admin)) {
            return false;
        }
        Admin other = (Admin) object;
        if ((this.user == null && other.user != null) || (this.user != null && !this.user.equals(other.user))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.classnet.db.Admin[user=" + user + "]";
    }

}
